package redis

import (
	"encoding/json"
	"rpc/model/mysql"
	"strconv"
)

func SyncLevel(userId int, level int) {
	key := "level:user_id_" + strconv.Itoa(userId)
	for i := 0; i < level; i++ {
		Rdb.LPush(key, userId)
	}
}
func SyncUser(user *mysql.User) {
	key := "user:user_id_" + strconv.Itoa(int(user.ID))
	marshal, _ := json.Marshal(user)
	var m map[string]interface{}
	json.Unmarshal(marshal, &m)
	Rdb.HMSet(key, m)
}

// 判断会员状态
func IsNull(useId int) string {
	key := "user:user_id" + strconv.Itoa(useId)
	return Rdb.HGet(key, "Checked").Val()
}
